<?

define('SYSPATH', 'NEED');

class Template_Controller{

}
 
  include('/home/webnizer/public_html/c-net/application/controllers/web.php') ;;
  include('/home/webnizer/public_html/c-net/application/libraries/jsmin-1.1.1.php') ;;

 
// Output a minified version of example.js.

(scan_directory_recursively(SERVER_PATH, 'js'));
(scan_directory_recursively(SERVER_PATH, 'css'));

// ------------ lixlpixel recursive PHP functions -------------
// scan_directory_recursively( directory to scan, filter )
// expects path to directory and optional an extension to filter
// ------------------------------------------------------------
function scan_directory_recursively($directory, $filter=FALSE)
{
	if(substr($directory,-1) == '/')
	{
		$directory = substr($directory,0,-1);
	}
	if(!file_exists($directory) || !is_dir($directory))
	{
		return FALSE;
	}elseif(is_readable($directory))
	{
		$directory_list = opendir($directory);
		while($file = readdir($directory_list))
		{
			if($file != '.' && $file != '..')
			{
				$path = $directory.'/'.$file;
				if(is_readable($path))
				{
					$subdirectories = explode('/',$path);
					if(is_dir($path))
					{
						$directory_tree[] = array(
							'path'      => $path,
							'name'      => end($subdirectories),
							'kind'      => 'directory',
							'content'   => scan_directory_recursively($path, $filter));
					}elseif(is_file($path))
					{
						$extension = end(explode('.',end($subdirectories)));
						if($filter === FALSE || $filter == $extension)
						{
							$directory_tree[] = array(
							'path'		=> $path,
							'name'		=> end($subdirectories),
							'extension' => $extension,
							'size'		=> filesize($path),
							'kind'		=> 'file');
							
							try {
								file_put_contents($path, JSMin::minify(file_get_contents($path)));
							} catch(Exception $e) {
								echo '#Error: ' .$e->getMessage();
							}
							
						}
					}
				}
			}
		}
		closedir($directory_list); 
		return $directory_tree;
	}else{
		return FALSE;	
	}
}
// ------------------------------------------------------------
 

?> 